package com.project.web.admin.controller.core;

import com.project.web.admin.controller.common.BaseController;
import com.project.web.admin.service.common.SysConfigService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import org.yun.common.utils.setting.Setting;

import javax.annotation.Resource;

/**
 * 系统设置
 */
@Controller("adminSettingController")
@RequestMapping("/admin/setting")
public class SettingController extends BaseController {

    private static final long serialVersionUID = -6509016314209214457L;

    @Resource(name = "sysConfigServiceImpl")
    private SysConfigService sysConfigService;

    /**
     * 编辑(其他)
     */
    @RequestMapping(value = "/editOtherSetting", method = RequestMethod.GET)
    public String editOtherSetting() {
        return "/intfc/core/setting/otherSetting_edit.ftl";
    }

    /**
     * 更新(其他)
     *
     * @return
     */
    @RequestMapping(value = "/updateOtherSetting", method = RequestMethod.POST)
    public String updateOtherSetting(Setting setting, RedirectAttributes redirectAttributes) {
        sysConfigService.set(setting);
        addFlashMessage(redirectAttributes, SUCCESS_MESSAGE);
        return "redirect:editOtherSetting.jhtml";
    }

}
